# -*- coding: utf-8 -*- 
# @Time : 2021/4/9 21:29 
# @Author : Dong 
# @File : return_headers.py

import re


def headers_to_dict(headers_str, out_put=True):
    items = headers_str.strip().split('\n')
    headers_dict = {}
    for t in items:
        key, value = re.findall(r'^(\S+):\s*([\s\S]+)$', t)[0]
        headers_dict[key] = value
        if out_put:
            print(f"'{key}': '{value}',")
    return headers_dict


headers_to_dict('''Accept: application/json, text/javascript, */*; q=0.01
Accept-Encoding: gzip, deflate, br
Accept-Language: en,zh-CN;q=0.9,zh;q=0.8
Connection: keep-alive
Cookie: Hm_lvt_d24dcf008a97469875a4da33090711f9=1617974215; Hm_lpvt_d24dcf008a97469875a4da33090711f9=1617974215; __utma=53386493.670124061.1617974211.1617974211.1617974211.1; __utmc=53386493; __utmz=53386493.1617974211.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utmt=1; __utmb=53386493.1.10.1617974211; _fbp=fb.1.1617974217681.1200694037
Host: droptokyo.com
Referer: https://droptokyo.com/freshsnaps/?page_num=4
sec-ch-ua: "Google Chrome";v="89", "Chromium";v="89", ";Not A Brand";v="99"
sec-ch-ua-mobile: ?0
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36
X-Requested-With: XMLHttpRequest''')
